/******************************************************************************
 * @File name   :      ResetPasswordController.java
 *
 * @Author      :      chen shixiang
 *
 * @Date        :      2011-6-22
 *
 * @Copyright Notice: 
 * Copyright (c) 2014 DMS, Inc. All  Rights Reserved.
 * This software is published under the terms of the DMS Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * 
 * ----------------------------------------------------------------------------
 * Date                   Who         Version        Comments
 * 2011-6-22 下午01:24:51        chen shixiang     1.0            Initial Version
 * 2011-6-22 下午4:28:51        HeHao     1.1            Change Method getUserCertificateType
 *****************************************************************************/
package com.cap.bts.framework.ge.resetpassword.conntroller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.cap.bts.framework.common.controller.BaseController;
import com.cap.bts.framework.common.exception.AppException;
import com.cap.bts.framework.ge.resetpassword.dto.CertificateDto;
import com.cap.bts.framework.ge.resetpassword.dto.ResetPasswordDto;
import com.cap.bts.framework.ge.resetpassword.dto.UserInfoDto;
import com.cap.bts.framework.ge.resetpassword.service.IResetPasswordService;
import com.cap.bts.framework.workbench.userlogin.dto.OperationPwdDto;

/**
 *
 */
@Controller
@RequestMapping(value = "/ge/dealer/resetpasswd")
public class ResetPasswordController extends BaseController {

    @Autowired
    IResetPasswordService resetPasswordService;

    /**
     * get user info by code
     * @Date        :      2011-6-22
     * @param userCode user code
     * @return CertificateDto
     * @throws AppException AppException
     */
    @RequestMapping(value="/getUseByCode/{userCode}",method = RequestMethod.GET)
    public @ResponseBody
    CertificateDto getUserCertificateType(@PathVariable("userCode") String userCode)
        throws AppException {
//        CertificateDto cer = resetPasswordService.getUserCertificateType(userCode);
//        return cer;
    	return null;
    }
    /**
     * check user
     * @Date        :      2011-6-22
     * @param resetPasswordDto ResetPasswordDto
     * @return
     * @throws AppException AppException
     */
    @RequestMapping(value="/resetPassword",method = RequestMethod.POST)
    public @ResponseBody
    UserInfoDto resetPassword(UserInfoDto userInfoDto)
        throws AppException {
        return resetPasswordService.verifyResetPasswordRequest(userInfoDto);
//    	return true;
    }
    
    /**
     * check user
     * @Date        :      2011-6-22
     * @param resetPasswordDto ResetPasswordDto
     * @return
     * @throws AppException AppException
     */
    @RequestMapping(value="/validationUser",method = RequestMethod.POST)
    public @ResponseBody
    boolean validationUser(ResetPasswordDto resetPasswordDto)
        throws AppException {
        //return resetPasswordService.validationUser(resetPasswordDto);
    	return true;
    }
    /**
     * to reset password
     * @Date        :      2011-6-22
     * @return ModelAndView
     */
    @RequestMapping(value="/toResetPwd",method = RequestMethod.GET)
    public ModelAndView toResetPwd(Model model){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("resetPasswordDto", new ResetPasswordDto());
        return new ModelAndView("/workbench/resetpwd",map);
    }

    
    /**
     * @Date        :      2015年7月28日
     * @param operationPwdDto
     * @return
     * @throws AppException
     */
    @RequestMapping(value="/sendOperationPwd",method = RequestMethod.POST)
    public @ResponseBody
    OperationPwdDto sendOperationPwd(OperationPwdDto operationPwdDto) throws AppException {
        return resetPasswordService.verifyResetOperationPwdRequest(operationPwdDto);
    }
}
